package com.hotagent.reload;

import java.lang.instrument.Instrumentation;
import java.util.ArrayList;
import java.util.List;

public class Reloader {

    private Instrumentation ins;

    public Reloader(Instrumentation ins) {
        this.ins = ins;
    }

    public Result reload() {
        Result result = new Result();
        List<HotDeployer> hotDeployers = new ArrayList<>();
        hotDeployers.add(new HotAgentHotDeployer(result, ins));
        hotDeployers.add(new HotDeployHotDeployer(result, ins));

        for (HotDeployer hotDeployer : hotDeployers) {
            if (!hotDeployer.exec().isResult()) {
                break;
            }
        }
        return result;
    }

}
